package com.springboot.shiro.config.redis;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;
import org.apache.shiro.util.Destroyable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @Date: 2019/10/25 16:40
 * @author: ybzhu
 * @Description： 重写 shiro的 CacheManager、Destroyable
 */
public class RedisShiroCacheManager implements CacheManager, Destroyable {

    @Autowired
    private RedisTemplate sessionTemplate;


    @Override
    public <K, V> Cache<K, V> getCache(String s) throws CacheException {
        return new RedisCache<>(sessionTemplate);
    }

    @Override
    public void destroy() {

    }
}
